/*
* Copyright (c) 2010 Michael Collins
*
* This file is part of TerraFirma.
*
* TerraFirma is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TerraFirma is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TerraFirma.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef DEBUG
#include "message_header.h"
#include <string>
namespace engine
{
    static const char* major_type_str [] = {
        "NULL ", "CONTROL ", "SOUND ", "GAME ", "NETWORK ", "VIDEO ",
        "BROADCAST-PAUSE ", "BROADCAST-CLOSE ", "BROADCAST-ERROR "};

    static const char* game_type_str[] = {
        "PLAYER_ADD ", "PLAYER_UPDATE ", "PLAYER_REMOVE ",
        "ENTITY_CREATE ", "ENTITY_UPDATE ", "ENTITY_DESTROY ",
        "CONTROL_EVENT ", "REQUEST_JOIN ", "ACCEPT_JOIN "};

    std::ostream& operator << (std::ostream& os, const message_header& m)
    {
        std::string s(major_type_str[m.major_type() >> 4]); //m is set to the major-type string
        if(m.major_type() == GAME_MSG)
            s += game_type_str[m.minor_type()];
        return os << s;
    }
}


#endif
